var arr=[3322,245,387,2,1246]
var max =min =arr[0];
for(var i=1;i++;i<arr.length){
    if(arr[i]>max){max=arr[i]}
    if(arr[i]<min){min=arr[i]}
}
console.log('最大值为'+max,'最小值为'+min)